package com.daocao.hua.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.daocao.hua.R;
import com.daocao.hua.adapter.base.ItemAdapter;
import com.daocao.hua.view.Dialog;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * Created by xsooy-pc on 2017/10/23.
 */

public class V3IdentityInfoPhotoAdapter extends ItemAdapter<String, V3IdentityInfoPhotoAdapter.DefaultHolder> {


    private Context context;

    public V3IdentityInfoPhotoAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public DefaultHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new DefaultHolder(inflate(R.layout.item_identity_info_photo, parent));
    }

    @Override
    public void onBindViewHolder(DefaultHolder holder, int position) {
        String item = getItem(position);
        Glide.with(context).load(item).into(holder.imgPhoto);
        holder.imgPhoto.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Dialog.showBigIcon(context, item);
            }
        });
    }

    class DefaultHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.img_photo)
        ImageView imgPhoto;

        public DefaultHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
